package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.EquipmentStatus;
import com.ruoyi.system.mapper.EquipmentStatusMapper;
import com.ruoyi.system.service.IEquipmentStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 设备状态Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-19
 */
@Service
public class EquipmentStatusServiceImpl implements IEquipmentStatusService {
    @Autowired
    private EquipmentStatusMapper equipmentStatusMapper;

    /**
     * 查询设备状态
     *
     * @param equipmentId 设备状态主键
     * @return 设备状态
     */
    @Override
    public EquipmentStatus selectEquipmentStatusByEquipmentId(String equipmentId) {
        return equipmentStatusMapper.selectEquipmentStatusByEquipmentId(equipmentId);
    }

    /**
     * 查询设备状态列表
     *
     * @param equipmentStatus 设备状态
     * @return 设备状态
     */
    @Override
    public List<EquipmentStatus> selectEquipmentStatusList(EquipmentStatus equipmentStatus) {
        return equipmentStatusMapper.selectEquipmentStatusList(equipmentStatus);
    }

    /**
     * 新增设备状态
     *
     * @param equipmentStatus 设备状态
     * @return 结果
     */
    @Override
    public int insertEquipmentStatus(EquipmentStatus equipmentStatus) {
        equipmentStatus.setCreateTime(DateUtils.getNowDate());
        return equipmentStatusMapper.insertEquipmentStatus(equipmentStatus);
    }

    /**
     * 修改设备状态
     *
     * @param equipmentStatus 设备状态
     * @return 结果
     */
    @Override
    public int updateEquipmentStatus(EquipmentStatus equipmentStatus) {
        equipmentStatus.setStatus("故障");
        return equipmentStatusMapper.updateEquipmentStatus(equipmentStatus);
    }

    /**
     * 批量删除设备状态
     *
     * @param equipmentIds 需要删除的设备状态主键
     * @return 结果
     */
    @Override
    public int deleteEquipmentStatusByEquipmentIds(String[] equipmentIds) {
        return equipmentStatusMapper.deleteEquipmentStatusByEquipmentIds(equipmentIds);
    }

    /**
     * 删除设备状态信息
     *
     * @param equipmentId 设备状态主键
     * @return 结果
     */
    @Override
    public int deleteEquipmentStatusByEquipmentId(String equipmentId) {
        return equipmentStatusMapper.deleteEquipmentStatusByEquipmentId(equipmentId);
    }
}
